<?php
/**
 * 注：此模板为自动生成模板，需要根据实际情况调整修改
 * 此模板对 无主键/单一主键 表的支持较好，联合主键表在下一版本开发
 */
namespace Data;

use Utils\MyException;

class Order_form {

    //数组
    private $array;


    public function __construct ($array){

        $this->array = $array;

        self::setDefault();

    }

    public function getArray() {
        return $this->array;
    }

    public function updateWithArray($array) {
        foreach($array as $key=>$value)
        {
            if(array_key_exists($key,$this->array))
            {
                $this->array = array_merge($this->array,array($key=>$value));
            }
        }
    }



    private function setDefault(){

        if(count($this->array)==0){
            self::setORDER_FORM_ID("null");
            self::setORDER_NUM("0");
            self::setRESTAURANT_ID("0");
            self::setTABLE_NUM("0");
            self::setTOTAL_PRICE("0");
            self::setTOTAL_PRICE_LEFT("0");
            self::setCONSUMER_COUNT("0");
            self::setIS_TAKE_OUT("0");
            self::setLUNCHBOX_TOTAL_AMOUNTS("0");
            self::setLUNCHBOX_TOTAL_AMOUNTS_LEFT("0");
            self::setLUNCHBOX_TOTAL_PRICE("0");
            self::setLUNCHBOX_TOTAL_PRICE_LEFT("0");
            self::setPAY_WAY("0");
            self::setPAY_TIME("");
            self::setPAY_STATUS("0");
            self::setPAY_FAIL_REASON("0");
            self::setRETREAT_ORDER_STATUS("0");
            self::setRETREAT_FOOD_STATUS("0");
            self::setREMINDER_STATUS("0");
            self::setREMINDER_TIME("");
            self::setIS_ENTRY("0");
            self::setDATE("");
            self::setCREATED_ON("");
            self::setCREATED_BY("0");
            self::setUPDATED_ON("");
            self::setUPDATED_BY("0");

        }
    }






    public function setORDER_FORM_ID($value) {
        $this->array = array_merge ($this->array,array(
            'ORDER_FORM_ID' => $value));
    }
    public function getORDER_FORM_ID(){

        return $this->array ['ORDER_FORM_ID'];
    }


    public function setORDER_NUM($value) {
        $this->array = array_merge ($this->array,array(
            'ORDER_NUM' => $value));
    }
    public function getORDER_NUM(){

        return $this->array ['ORDER_NUM'];
    }


    public function setRESTAURANT_ID($value) {
        $this->array = array_merge ($this->array,array(
            'RESTAURANT_ID' => $value));
    }
    public function getRESTAURANT_ID(){

        return $this->array ['RESTAURANT_ID'];
    }


    public function setTABLE_NUM($value) {
        $this->array = array_merge ($this->array,array(
            'TABLE_NUM' => $value));
    }
    public function getTABLE_NUM(){

        return $this->array ['TABLE_NUM'];
    }


    public function setTOTAL_PRICE($value) {
        $this->array = array_merge ($this->array,array(
            'TOTAL_PRICE' => $value));
    }
    public function getTOTAL_PRICE(){

        return $this->array ['TOTAL_PRICE'];
    }


    public function setTOTAL_PRICE_LEFT($value) {
        $this->array = array_merge ($this->array,array(
            'TOTAL_PRICE_LEFT' => $value));
    }
    public function getTOTAL_PRICE_LEFT(){

        return $this->array ['TOTAL_PRICE_LEFT'];
    }


    public function setCONSUMER_COUNT($value) {
        $this->array = array_merge ($this->array,array(
            'CONSUMER_COUNT' => $value));
    }
    public function getCONSUMER_COUNT(){

        return $this->array ['CONSUMER_COUNT'];
    }


    public function setIS_TAKE_OUT($value) {
        $this->array = array_merge ($this->array,array(
            'IS_TAKE_OUT' => $value));
    }
    public function getIS_TAKE_OUT(){

        return $this->array ['IS_TAKE_OUT'];
    }


    public function setLUNCHBOX_TOTAL_AMOUNTS($value) {
        $this->array = array_merge ($this->array,array(
            'LUNCHBOX_TOTAL_AMOUNTS' => $value));
    }
    public function getLUNCHBOX_TOTAL_AMOUNTS(){

        return $this->array ['LUNCHBOX_TOTAL_AMOUNTS'];
    }


    public function setLUNCHBOX_TOTAL_AMOUNTS_LEFT($value) {
        $this->array = array_merge ($this->array,array(
            'LUNCHBOX_TOTAL_AMOUNTS_LEFT' => $value));
    }
    public function getLUNCHBOX_TOTAL_AMOUNTS_LEFT(){

        return $this->array ['LUNCHBOX_TOTAL_AMOUNTS_LEFT'];
    }


    public function setLUNCHBOX_TOTAL_PRICE($value) {
        $this->array = array_merge ($this->array,array(
            'LUNCHBOX_TOTAL_PRICE' => $value));
    }
    public function getLUNCHBOX_TOTAL_PRICE(){

        return $this->array ['LUNCHBOX_TOTAL_PRICE'];
    }


    public function setLUNCHBOX_TOTAL_PRICE_LEFT($value) {
        $this->array = array_merge ($this->array,array(
            'LUNCHBOX_TOTAL_PRICE_LEFT' => $value));
    }
    public function getLUNCHBOX_TOTAL_PRICE_LEFT(){

        return $this->array ['LUNCHBOX_TOTAL_PRICE_LEFT'];
    }


    public function setPAY_WAY($value) {
        $this->array = array_merge ($this->array,array(
            'PAY_WAY' => $value));
    }
    public function getPAY_WAY(){

        return $this->array ['PAY_WAY'];
    }


    public function setPAY_TIME($value) {
        $this->array = array_merge ($this->array,array(
            'PAY_TIME' => $value));
    }
    public function getPAY_TIME(){

        return $this->array ['PAY_TIME'];
    }


    public function setPAY_STATUS($value) {
        $this->array = array_merge ($this->array,array(
            'PAY_STATUS' => $value));
    }
    public function getPAY_STATUS(){

        return $this->array ['PAY_STATUS'];
    }


    public function setPAY_FAIL_REASON($value) {
        $this->array = array_merge ($this->array,array(
            'PAY_FAIL_REASON' => $value));
    }
    public function getPAY_FAIL_REASON(){

        return $this->array ['PAY_FAIL_REASON'];
    }


    public function setRETREAT_ORDER_STATUS($value) {
        $this->array = array_merge ($this->array,array(
            'RETREAT_ORDER_STATUS' => $value));
    }
    public function getRETREAT_ORDER_STATUS(){

        return $this->array ['RETREAT_ORDER_STATUS'];
    }


    public function setRETREAT_FOOD_STATUS($value) {
        $this->array = array_merge ($this->array,array(
            'RETREAT_FOOD_STATUS' => $value));
    }
    public function getRETREAT_FOOD_STATUS(){

        return $this->array ['RETREAT_FOOD_STATUS'];
    }


    public function setREMINDER_STATUS($value) {
        $this->array = array_merge ($this->array,array(
            'REMINDER_STATUS' => $value));
    }
    public function getREMINDER_STATUS(){

        return $this->array ['REMINDER_STATUS'];
    }


    public function setREMINDER_TIME($value) {
        $this->array = array_merge ($this->array,array(
            'REMINDER_TIME' => $value));
    }
    public function getREMINDER_TIME(){

        return $this->array ['REMINDER_TIME'];
    }


    public function setIS_ENTRY($value) {
        $this->array = array_merge ($this->array,array(
            'IS_ENTRY' => $value));
    }
    public function getIS_ENTRY(){

        return $this->array ['IS_ENTRY'];
    }


    public function setDATE($value) {
        $this->array = array_merge ($this->array,array(
            'DATE' => $value));
    }
    public function getDATE(){

        return $this->array ['DATE'];
    }


    public function setCREATED_ON($value) {
        $this->array = array_merge ($this->array,array(
            'CREATED_ON' => $value));
    }
    public function getCREATED_ON(){

        return $this->array ['CREATED_ON'];
    }


    public function setCREATED_BY($value) {
        $this->array = array_merge ($this->array,array(
            'CREATED_BY' => $value));
    }
    public function getCREATED_BY(){

        return $this->array ['CREATED_BY'];
    }


    public function setUPDATED_ON($value) {
        $this->array = array_merge ($this->array,array(
            'UPDATED_ON' => $value));
    }
    public function getUPDATED_ON(){

        return $this->array ['UPDATED_ON'];
    }


    public function setUPDATED_BY($value) {
        $this->array = array_merge ($this->array,array(
            'UPDATED_BY' => $value));
    }
    public function getUPDATED_BY(){

        return $this->array ['UPDATED_BY'];
    }


    public function toInsertCSV() {
        $str="";

        // ORDER_FORM_ID
        $str .= self::getORDER_FORM_ID().",";
        // ORDER_NUM
        $str .= "'". self::getORDER_NUM()."',";
        // RESTAURANT_ID
        $str .= "'". self::getRESTAURANT_ID()."',";
        // TABLE_NUM
        $str .= "'". self::getTABLE_NUM()."',";
        // TOTAL_PRICE
        $str .= "'". self::getTOTAL_PRICE()."',";
        // TOTAL_PRICE_LEFT
        $str .= "'". self::getTOTAL_PRICE_LEFT()."',";
        // CONSUMER_COUNT
        $str .= "'". self::getCONSUMER_COUNT()."',";
        // IS_TAKE_OUT
        $str .= "'". self::getIS_TAKE_OUT()."',";
        // LUNCHBOX_TOTAL_AMOUNTS
        $str .= "'". self::getLUNCHBOX_TOTAL_AMOUNTS()."',";
        // LUNCHBOX_TOTAL_AMOUNTS_LEFT
        $str .= "'". self::getLUNCHBOX_TOTAL_AMOUNTS_LEFT()."',";
        // LUNCHBOX_TOTAL_PRICE
        $str .= "'". self::getLUNCHBOX_TOTAL_PRICE()."',";
        // LUNCHBOX_TOTAL_PRICE_LEFT
        $str .= "'". self::getLUNCHBOX_TOTAL_PRICE_LEFT()."',";
        // PAY_WAY
        $str .= "'". self::getPAY_WAY()."',";
        // PAY_TIME
        $str .= "'". self::getPAY_TIME()."',";
        // PAY_STATUS
        $str .= "'". self::getPAY_STATUS()."',";
        // PAY_FAIL_REASON
        $str .= "'". self::getPAY_FAIL_REASON()."',";
        // RETREAT_ORDER_STATUS
        $str .= "'". self::getRETREAT_ORDER_STATUS()."',";
        // RETREAT_FOOD_STATUS
        $str .= "'". self::getRETREAT_FOOD_STATUS()."',";
        // REMINDER_STATUS
        $str .= "'". self::getREMINDER_STATUS()."',";
        // REMINDER_TIME
        $str .= "'". self::getREMINDER_TIME()."',";
        // IS_ENTRY
        $str .= "'". self::getIS_ENTRY()."',";
        // DATE
        $str .= "'". self::getDATE()."',";
        // CREATED_ON
        $str .= "now()" . ",";

        // CREATED_BY
        $str .= "'". self::getCREATED_BY()."',";
        // UPDATED_ON
        $str .= "now()" . ",";

        // UPDATED_BY
        $str .= "'". self::getUPDATED_BY()."'";
        return $str;
    }



    public function toUpdateSet() {
        $str="";

        // ORDER_NUM
        $str.= '`ORDER_NUM` = "' . self::getORDER_NUM() . '",';

        // RESTAURANT_ID
        $str.= '`RESTAURANT_ID` = "' . self::getRESTAURANT_ID() . '",';

        // TABLE_NUM
        $str.= '`TABLE_NUM` = "' . self::getTABLE_NUM() . '",';

        // TOTAL_PRICE
        $str.= '`TOTAL_PRICE` = "' . self::getTOTAL_PRICE() . '",';

        // TOTAL_PRICE_LEFT
        $str.= '`TOTAL_PRICE_LEFT` = "' . self::getTOTAL_PRICE_LEFT() . '",';

        // CONSUMER_COUNT
        $str.= '`CONSUMER_COUNT` = "' . self::getCONSUMER_COUNT() . '",';

        // IS_TAKE_OUT
        $str.= '`IS_TAKE_OUT` = "' . self::getIS_TAKE_OUT() . '",';

        // LUNCHBOX_TOTAL_AMOUNTS
        $str.= '`LUNCHBOX_TOTAL_AMOUNTS` = "' . self::getLUNCHBOX_TOTAL_AMOUNTS() . '",';

        // LUNCHBOX_TOTAL_AMOUNTS_LEFT
        $str.= '`LUNCHBOX_TOTAL_AMOUNTS_LEFT` = "' . self::getLUNCHBOX_TOTAL_AMOUNTS_LEFT() . '",';

        // LUNCHBOX_TOTAL_PRICE
        $str.= '`LUNCHBOX_TOTAL_PRICE` = "' . self::getLUNCHBOX_TOTAL_PRICE() . '",';

        // LUNCHBOX_TOTAL_PRICE_LEFT
        $str.= '`LUNCHBOX_TOTAL_PRICE_LEFT` = "' . self::getLUNCHBOX_TOTAL_PRICE_LEFT() . '",';

        // PAY_WAY
        $str.= '`PAY_WAY` = "' . self::getPAY_WAY() . '",';

        // PAY_TIME
        $str.= '`PAY_TIME` = "' . self::getPAY_TIME() . '",';

        // PAY_STATUS
        $str.= '`PAY_STATUS` = "' . self::getPAY_STATUS() . '",';

        // PAY_FAIL_REASON
        $str.= '`PAY_FAIL_REASON` = "' . self::getPAY_FAIL_REASON() . '",';

        // RETREAT_ORDER_STATUS
        $str.= '`RETREAT_ORDER_STATUS` = "' . self::getRETREAT_ORDER_STATUS() . '",';

        // RETREAT_FOOD_STATUS
        $str.= '`RETREAT_FOOD_STATUS` = "' . self::getRETREAT_FOOD_STATUS() . '",';

        // REMINDER_STATUS
        $str.= '`REMINDER_STATUS` = "' . self::getREMINDER_STATUS() . '",';

        // REMINDER_TIME
        $str.= '`REMINDER_TIME` = "' . self::getREMINDER_TIME() . '",';

        // IS_ENTRY
        $str.= '`IS_ENTRY` = "' . self::getIS_ENTRY() . '",';

        // DATE
        $str.= '`DATE` = "' . self::getDATE() . '",';

        // CREATED_ON
        $str.= '`CREATED_ON` = "' . self::getCREATED_ON() . '",';

        // CREATED_BY
        $str.= '`CREATED_BY` = "' . self::getCREATED_BY() . '",';

        // UPDATED_ON
        $str .= "UPDATED_ON = now()," ;

        // UPDATED_BY
        $str.= '`UPDATED_BY` = "' . self::getUPDATED_BY(). '"';
        return $str;
    }



    public function toUpdateWhere(){
        $str = "";
        $str .= "`ORDER_FORM_ID` = '" . self::getORDER_FORM_ID()."'";
        return $str;
    }

}

